#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 - 2013 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1

#include <Macros.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Termstructures/Volatility/SmileSection.h>
#pragma unmanaged 
#include <ql\termstructures\volatility\spreadedsmilesection.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;
using namespace Cephei::Core;
using namespace PLATFORM::Collections;

using namespace Cephei::QL::Times;
using namespace Cephei::QL;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Termstructures { namespace Volatility {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of ISpreadedSmileSection
	public ref class CSpreadedSmileSection  : 
            public CSmileSection,
            public Cephei::QL::Termstructures::Volatility::ISpreadedSmileSection
	{
	protected: 
		boost::shared_ptr<QuantLib::SpreadedSmileSection>* _ppSpreadedSmileSection;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::SpreadedSmileSection>* _phSpreadedSmileSection;
#endif
		Object^ _SpreadedSmileSectionOwner;     // reference to object that manages the storage for this object
	internal:
		CSpreadedSmileSection (Cephei::QL::Termstructures::Volatility::ISmileSection^ underlyingSection, Cephei::QL::IQuote^ spread);
        CSpreadedSmileSection (boost::shared_ptr<QuantLib::SpreadedSmileSection>& childNative, Object^ owner);
        CSpreadedSmileSection (QuantLib::SpreadedSmileSection& childNative, Object^ owner);
        CSpreadedSmileSection (CSpreadedSmileSection^ copy);
        CSpreadedSmileSection (PLATFORM::Type^ t);
#ifdef STRUCT
        CSpreadedSmileSection (QuantLib::SpreadedSmileSection childNative);
#endif       
#ifdef HANDLE
		CSpreadedSmileSection (QuantLib::Handle<QuantLib::SpreadedSmileSection>& childNative, Object^ owner);
		CSpreadedSmileSection (QuantLib::Handle<QuantLib::SpreadedSmileSection> childNative);
#endif
		virtual ~CSpreadedSmileSection ();
		!CSpreadedSmileSection ();

	internal:
		QuantLib::SpreadedSmileSection& GetReference ();
		boost::shared_ptr<QuantLib::SpreadedSmileSection>& GetShared ();
		QuantLib::SpreadedSmileSection* GetPointer ();
        void SetSpreadedSmileSection (boost::shared_ptr<QuantLib::SpreadedSmileSection> native)
        {
            if (_ppSpreadedSmileSection != NULL)
                delete _ppSpreadedSmileSection;
            _ppSpreadedSmileSection = new boost::shared_ptr<QuantLib::SpreadedSmileSection> (native);
            SetSmileSection (boost::dynamic_pointer_cast<QuantLib::SmileSection> (*_ppSpreadedSmileSection));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::SpreadedSmileSection>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
        property Double AtmLevel 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::Times::IDayCounter^ DayCounter 
        {
		    virtual Cephei::QL::Times::IDayCounter^ get () ;
        }
        property DateTime ExerciseDate 
        {
		    virtual DateTime get () ;
        }
        property Double ExerciseTime 
        {
		    virtual Double get () ;
        }
        property Double MaxStrike 
        {
		    virtual Double get () ;
        }
        property Double MinStrike 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::Termstructures::Volatility::ISpreadedSmileSection^ Update 
        {
		    virtual Cephei::QL::Termstructures::Volatility::ISpreadedSmileSection^ get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
//z	[FactoryFor(Core::Generic::ICoCell<Cephei::QL::Termstructures::Volatility::ISpreadedSmileSection^>::typeid)]
	[FactoryFor(Cephei::QL::Termstructures::Volatility::ISpreadedSmileSection::typeid)]
	[FactoryFor(Cephei::QL::Termstructures::Volatility::ISpreadedSmileSection_Factory::typeid)]
	public ref class CSpreadedSmileSection_Factory sealed : public ISpreadedSmileSection_Factory
	{
	public:
        virtual ISpreadedSmileSection^ Create (Cephei::QL::Termstructures::Volatility::ISmileSection^ underlyingSection, Cephei::QL::IQuote^ spread);
    };
   
/*Cephei*/ } /*QL*/ } /*Termstructures*/ } /*Volatility */}
